import abc
from coin.support.telemetry.latency_recorder import LifeOfSignal, use_latency_recorder


class AggressiveExecutorInterface(metaclass=abc.ABCMeta):
  def submit_agg_order(self, *, order_side, order_price, order_qty):
    # It merely checks the obvious validity of the input. Do not
    # adjust inputs in the interface level.

    assert order_side is not None
    assert order_price is not None
    assert order_price > 0

    if order_qty is not None:
      assert order_qty > 0

    return self.submit_agg_order_impl(order_side=order_side,
                                      order_price=order_price,
                                      order_qty=order_qty)

  def manage_agg_orders(self):
    with use_latency_recorder(self._latency_recorder,
                              LifeOfSignal.BEFORE_MANAGE_AGG_ORDERS,
                              LifeOfSignal.AFTER_MANAGE_AGG_ORDERS):
      return self.manage_agg_orders_impl()

  @abc.abstractmethod
  def submit_agg_order_impl(self):
    raise NotImplementedError()

  @abc.abstractmethod
  def manage_agg_orders_impl(self):
    raise NotImplementedError()
